package com.jkoss.dao.oa;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jkoss.pojo.oa.Empqinjia;
import com.jkoss.pojo.oa.EmpqinjiaExample;

public interface EmpqinjiaMapper {

	@Select("SELECT  eid   FROM t_empqinjia  where  sqjid=#{sqjid}")
	@ResultType(java.lang.Integer.class)
	Integer findEidBySqjid(int  sqjid);
	
	@Select("SELECT  sqjdate   FROM t_empqinjia  where  sqjid=#{sqjid}")
	@ResultType(java.util.Date.class)
	Date findSqjdateBySqjid(int  sqjid);
	
	@Select("SELECT  sqjid,eid,t_e_eid,sqjdate,left(sqjdesc,12) as sqjreson,sqjqueren,sqjstate,sqjbegin,sqjend,sqjcnfm,sqjdesc FROM t_empqinjia  where  eid=#{empid} and sqjbegin BETWEEN #{bgn} and #{end}  ORDER  by  sqjbegin desc,sqjid desc")
	List<Empqinjia> findAllAyearByEid(@Param("empid") int empid,@Param("bgn") Date begin,@Param("end") Date end); 
	
	@Select("SELECT  a.sqjid,a.eid,b.ename,a.t_e_eid,a.sqjdate,left(a.sqjdesc,12) as sqjreson,a.sqjqueren,a.sqjstate,a.sqjbegin,a.sqjend,a.sqjcnfm,a.sqjdesc from t_empqinjia a ,t_emps b,t_jobs c ,t_department d "
			+ " where a.eid=b.eid and c.jobid=b.jobid and d.depID=c.depID and d.depID=#{depID} and a.sqjbegin BETWEEN #{bgn} and #{end}  ORDER  by  a.sqjbegin desc,a.sqjid desc")
	@RequestMapping("com.jkoss.dao.oa.EmpqinjiaMapper.BaseResultMap2")
	List<Empqinjia> findAllAyearBydDptid(@Param("depID") int empid,@Param("bgn") Date begin,@Param("end") Date end); 
	
    int countByExample(EmpqinjiaExample example);

    @Delete("delete from t_empqinjia where eid=#{eid} and sqjdate between #{bfDate} and #{endDate}")
    void deleteEid_Sqjdate(@Param("eid") Integer eid,@Param("bfDate") Date bfDate,@Param("endDate") Date endDate);
    
    @Update("update t_empqinjia set t_e_eid=#{speid},sqjstate=#{sqjstate},sqjqueren=#{spnote} where eid=#{eid} and sqjdate between #{bfDate} and #{endDate}")
    void spQinjia(@Param("speid") int speid,@Param("sqjstate") int sqjstate,@Param("spnote") String spnote,@Param("eid") Integer eid,@Param("bfDate") Date bfDate,@Param("endDate") Date endDate);
    
    int deleteByExample(EmpqinjiaExample example);

    int deleteByPrimaryKey(Integer sqjid);

    int insert(Empqinjia record);

    int insertSelective(Empqinjia record);

    List<Empqinjia> selectByExample(EmpqinjiaExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_empqinjia
     *
     * @mbggenerated
     */
    Empqinjia selectByPrimaryKey(Integer sqjid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_empqinjia
     *
     * @mbggenerated
     */
    int updateByExampleSelective(@Param("record") Empqinjia record, @Param("example") EmpqinjiaExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_empqinjia
     *
     * @mbggenerated
     */
    int updateByExample(@Param("record") Empqinjia record, @Param("example") EmpqinjiaExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_empqinjia
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(Empqinjia record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_empqinjia
     *
     * @mbggenerated
     */
    int updateByPrimaryKey(Empqinjia record);
}